package com.example.weather_forecast;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

import java.util.List;

@Dao
public interface CityDao {

    @Insert
    void insert(City city);

    @Delete
    void delete(City city);

    @Query("SELECT * FROM city ORDER BY name ASC")
    List<City> getAllCities();

    @Query("SELECT * FROM city WHERE name LIKE :cityName LIMIT 1")
    City findCityByName(String cityName);

    // 新增模糊搜索功能
    @Query("SELECT * FROM city WHERE name LIKE :query")
    List<City> searchCities(String query);  // 用于模糊搜索
}

